import java.util.Scanner;

public class Solution1 {
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            int year = scan.nextInt();
            int month = scan.nextInt();
            int day = scan.nextInt();
            int[] array = {0,31,28,31,30,31,30,31,31,30,31,30,31};
            boolean ret = is_Leap_year(year);
            if(ret) {
                array[2] = 29;
            }
            int month_count = 0;
            for (int i = 0; i < month; i++) {
                month_count += array[i];
            }
            System.out.println(month_count+day);
        }
        public static boolean is_Leap_year(int year) {
            if(year % 4 == 0 && year % 100 !=0 ||year %400 != 0) {
                return true;
            }else {
                return false;
            }
        }
}
